package edu.sctu.zhuyingzhi.month201505.day20150527.studentToEatTest;

import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

/**
 * Created by user13 on 2015/5/27.
 */
public class Student {
    private String name;
    private int age;
    private String className;
    private Card studentCard = new Card(1406101038,90,"王大锤");

    Stomach stomach = new Stomach();
    Conteen conteen = new Conteen();
    Scanner in = new Scanner(System.in);

    public Student(String name,int age,String className){
        this.age = age;
        this.className = className;
        this.name = name;
    }

    /**
     * 自我介绍 旁白
     */
    public void introduce() throws InterruptedException {
        Introduce introduce = new Introduce();
        introduce.confession();
        Thread.sleep(3000);
    }

    /**
     * 起床的时候
     */
    public void getUp() throws InterruptedException {

        stomach.becomeHungry();

    }

    /**
     * 选择去食堂的路线
     */
    public void choiceRoute() throws InterruptedException {
        String choice;
        boolean i = true;

        System.out.println("请输入去食堂的路线(A/B)：");


        while(i) {
            choice = in.next();

            switch (choice) {
                case "A":
                    System.out.println("大约1分钟 到达食堂" + " 风景差 无妹子");
                    i = false;
                    Thread.sleep(3000);
                    System.out.println("到达食堂");
                    Thread.sleep(1000);
                    break;

                case "B":
                    System.out.println("大约2分钟到达食堂" + " 沿途妹子多 秀色可餐");
                    i = false;
                    Thread.sleep(6000);
                    System.out.println("到达食堂");
                    Thread.sleep(1000);
                    break;
                default:
                    System.out.println("没有这条线路 请重新输入");
                    break;
            }
        }

    }

    /**
     * 选择楼层
     * @return
     */
    public HashMap<Integer,HashMap<String,Integer>> choiceFloor() throws InterruptedException {
        int floor;
        HashMap<Integer,HashMap<Integer,HashMap<String,Integer>>> conteenFloor = conteen.getConteen();
        System.out.println("今日 食堂里面的菜品有：");
        Thread.sleep(1000);
        for (int i = 1; i <= 3; i++) {
            System.out.println(" ");
            System.out.println(i+"楼"+"今日菜品");
            Thread.sleep(3000);
            if(i == 1){
                for (int j = 1; j <=3 ; j++) {
                    System.out.println(j+"号窗口");
                    System.out.println(conteenFloor.get(i).get(j));
                }
            }
            else{
                for (int j = 1; j <= 2; j++) {
                    System.out.println(j+"号窗口");
                    System.out.println(conteenFloor.get(i).get(j));
                }
            }
        }
        System.out.println("请输入你想要去的楼层");
        floor = Integer.parseInt(in.next());

        HashMap<Integer,HashMap<String,Integer>> conteenFloor1 = conteenFloor.get(floor);
        return conteenFloor1;
    }

    /**
     * 选择窗口
     * @return
     */
    public HashMap<String,Integer> choiceWindow() throws InterruptedException {
        int window;
        HashMap<Integer,HashMap<String,Integer>> conteenFloor = choiceFloor();

        System.out.println("你想要去的窗口");

        window = Integer.parseInt(in.next());

        HashMap<String,Integer> Floorwindow= conteenFloor.get(window);
        System.out.println("此窗口有："+Floorwindow);
        waitQueue();
        return Floorwindow;
    }

    /**
     * 排队
     * @throws InterruptedException
     */
    public void waitQueue() throws InterruptedException {

        int number = conteen.getQueueLone();
        System.out.println("当前队伍有"+number+"人等待：");
        System.out.println("请耐心等待"+number+"秒钟");

        for (int i = 1; i <= number; i++) {
            Thread.sleep(1000);
            System.out.println(i);
        }

    }

    /**
     * 消费的菜
     * @return
     */
    public float  choiceDishes() throws InterruptedException {
        float  count;
        String dishes;
        HashMap<String,Integer> window = choiceWindow();

        System.out.println("请选择你要吃的菜：");
        dishes = in.next();

        count = window.get(dishes);
        return count;

    }

    /**
     * 消费的米饭
     * @return
     */
    public float  choiceRice(){
        int judge;
        float count = 0;
        float weight = 0;
        System.out.println("米饭0.25元一两，是否需要米饭？（1/0）");
        judge = Integer.parseInt(in.next());

        if (judge == 1) {
            System.out.println("请输入你需要多少两的米饭：");
            weight = Integer.parseInt(in.next());
        }
        count = (float) (weight*0.25);
        System.out.println(count);
        return count;
    }

    /**
     * 学生的总消费
     * @throws InterruptedException
     */
    public void consume() throws InterruptedException {
        float balance;
        float price;

        price = choiceDishes()+ choiceRice();
        balance = studentCard.getMoney();

        System.out.println("校卡余额："+balance);
        System.out.println("本次消费共计:"+price);
        System.out.println("请支付");
        Thread.sleep(3000);

        System.out.println("支付成功");
        balance = balance-price;
        System.out.println("校卡余额："+balance);
    }

    /**
     * 学生选择位置
     */
    public void choiceSeat() throws InterruptedException {
        List<String> seat = conteen.getSeat();
        boolean x = true;
        int y;

        System.out.println("选择座位：");
        Thread.sleep(2000);
        for (int i = 1; i < seat.size(); i++) {
            System.out.print(i + "号桌" + seat.get(i) + "  ");
            if (i % 10 == 0)
                System.out.println(" ");
        }


        while(x){
            System.out.println(" ");
            System.out.println("请输入你想要坐的位置");
            y = Integer.parseInt(in.next());

            if(seat.get(y) == "有位子"){
                x = false;
                System.out.println("在"+y+"号位子就坐");
            }
            else {
                System.out.println("请重新选择位子");
            }
        }
    }

    /**
     * 吃饱了
     */
    public void leftConteen() throws InterruptedException {
        System.out.print("就餐中.");
        for (int i = 0; i < 30; i++) {
            Thread.sleep(1000);
            System.out.print(".");
        }
        stomach.becomeFull();
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public String getClassName() {
        return className;
    }
}
